package edu.fim.presentation.model.bean;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import edu.fim.data.Identifiable;

@Entity
@Table(name = "tb_portions")
public class Portion implements Identifiable<Integer> {

	private static final long serialVersionUID = 617083998090492434L;
	
	private Integer id;
	private Food food;
	private Double foodAmount;
	private Meal meal;
	
	public Portion() {
	}
	
	public Portion(Food food, Double foodAmount, Meal meal) {
		this.food = food;
		this.foodAmount = foodAmount;
		this.meal = meal;
	}

	public Portion(Integer id, Food food, Double foodAmount, Meal meal) {
		this(food, foodAmount, meal);
		this.id = id;
	}

	@Id
	@Column(name = "id")
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@ManyToOne(targetEntity = Food.class)
	@JoinColumn(name = "idFood")
	public Food getFood() {
		return food;
	}

	public void setFood(Food food) {
		this.food = food;
	}
	
	@Column(name = "amount")
	public Double getFoodAmount() {
		return foodAmount;
	}

	public void setFoodAmount(Double foodAmount) {
		this.foodAmount = foodAmount;
	}

	@ManyToOne(targetEntity = Meal.class)
	@JoinColumn(name = "idMeal")
	public Meal getMeal() {
		return meal;
	}

	public void setMeal(Meal meal) {
		this.meal = meal;
	}
}